﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace SBOConnectToV9
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                SAPbobsCOM.Company pCompany = new SAPbobsCOM.Company();
                pCompany.Server = "MANUELDIAS";
                pCompany.DbServerType = SAPbobsCOM.BoDataServerTypes.dst_MSSQL2008;
                pCompany.CompanyDB = "SBO_MEIRAL_PRD";
                pCompany.UseTrusted = false;
                pCompany.DbUserName = "sa";
                pCompany.DbPassword = "abaco";
                //            pCompany.language = SAPbobsCOM.BoSuppLangs.ln_Portuguese;
                pCompany.language = SAPbobsCOM.BoSuppLangs.ln_English;
                pCompany.UserName = "manager";
                pCompany.Password = "meiral";

                // Get SBO connection
                int iErrCode = pCompany.Connect();
                if (iErrCode != 0)
                {
                    string sErrorDesc = "";
                    pCompany.GetLastError(out iErrCode, out sErrorDesc);
                    throw new Exception(sErrorDesc + "(" + iErrCode.ToString());
                }
                pCompany.Disconnect();

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

        }

        private void Form1_Load(object sender, EventArgs e)
        {
            MessageBox.Show("mdias!");
        }
    }
}
